#include <iostream>
#include <vector>
using namespace std;
#define maxn 10005
const int INF = 1<<30;

int n,m;
vector<pair<int,int> > G[maxn];
int dis[maxn];
bool visited[maxn];
bool failure=false;

void SPFA(int u){
	visited[u]=true;
	for(auto son:G[u]){
		int v=son.first, w=son.second;
		if(dis[v] > dis[u]+w){
			if(visited[v]){
				failure=true;
				return;
			}
			dis[v] = dis[u]+w;
			SPFA(v);
		}
	}
	visited[u]=false;
}

int main(){
	for(int i=1;i<maxn;i++) dis[i]=INF;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int k,u,v,w=0;
		cin>>k>>u>>v;
		if(k!=3) cin>>w;
		if(k==1){
			swap(u,v);
			w = -w;
		}
		G[u].push_back(make_pair(v,w));
		if(k==3)
			G[v].push_back(make_pair(u,w));
	}
	for(int i=1;i<=n;i++){
		G[0].push_back(make_pair(i,0));
	}
	SPFA(0);
	if(failure) cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
	return 0;
}
